package com.gzx.plugin.data.wxjk.sync.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.gzx.plugin.data.wxjk.sync.dao.SssjDao;
import com.gzx.plugin.data.wxjk.sync.service.TsjgService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Slf4j
@DS("data")
public class TsjgServiceImpl implements TsjgService {
    @Autowired
    private SssjDao sssjDao;

    @Override
    public Map<String, String> query(Integer businessId) {
        Map<String, String> resultMap = new HashMap<>();//返回给接口调用方组装报文的map，json返回

        try {
            List<HashMap<String, Object>> map = sssjDao.query(businessId);
            if (!CollectionUtils.isEmpty(map)) {
                resultMap.put("code", "0");
                resultMap.put("statusCode", "0");
                resultMap.put("statusMessage", "数据推送成功");
                resultMap.put("message", "数据推送成功");
            } else {
                resultMap.put("code", "0");
                resultMap.put("statusCode", "2");
                resultMap.put("statusMessage", "订单未找到");
                resultMap.put("message", "订单未找到");
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return resultMap;
    }
}
